package com.bw.zg3.Cate.C1

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil.ItemCallback
import androidx.recyclerview.widget.RecyclerView
import com.bw.base.entity.C1EntityResultItem
import com.bw.zg3.R
import com.bw.zg3.databinding.C1Binding

class CLApter:PagingDataAdapter<C1EntityResultItem,CLApter.C1ViewHolder>(C1) {
    companion object{
        val C1=object:ItemCallback<C1EntityResultItem>(){
            override fun areItemsTheSame(
                oldItem: C1EntityResultItem,
                newItem: C1EntityResultItem,
            ): Boolean {
                return oldItem==newItem
            }

            override fun areContentsTheSame(
                oldItem: C1EntityResultItem,
                newItem: C1EntityResultItem,
            ): Boolean {
              return oldItem.id==newItem.id
            }

        }
    }
    class C1ViewHolder(view: View):RecyclerView.ViewHolder(view){
        val binding =DataBindingUtil.bind<C1Binding>(view)
    }
    override fun onBindViewHolder(holder: C1ViewHolder, position: Int) {
            holder.binding?.c1=getItem(position)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): C1ViewHolder {
        val inflate = LayoutInflater.from(parent.context).inflate(R.layout.c1, parent, false)
        return C1ViewHolder(inflate)


    }
}